#include "Iterator.h"

BASE(Iterator, None, 100)

//HIDDEN

//SHARED
IMPL(void, begin, List *list)
{
	THIS->pos = 0;
	THIS->list = list;
}

IMPL(int, hasNext)
{
	if(!THIS->list) return 0;
	if(THIS->pos>=C(THIS->list, size)()) return 0;
	return 1;
}

IMPL(void *, next)
{
	if(!C(hasNext)()) return 0;
	void *ptr = C(THIS->list, get)(THIS->pos++);
	return ptr;
}

SETUP_IF(ENTRY(hasNext), 
ENTRY(next), ENTRY(begin) )